﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using LoungeRepo.Contracts.Core;
using LoungeRepo.Core.Extensions;
using NUnit.Framework;
using Rhino.Mocks;

namespace Test.LoungeRepo.Core.Extensions
{
    [TestFixture]
    public class testILoungeRepositoryExtension
    {
        [Test]
        public void Prefetch_entities()
        {
            string repoPath = Environment.CurrentDirectory + @"\testrepo";
            RepoHelpers.CreateMockEntityFile(repoPath, "0.entity");
            RepoHelpers.CreateMockEntityFile(repoPath + "\\part1", "1a.entity");
            RepoHelpers.CreateMockEntityFile(repoPath + "\\part1\\part11", "11a.entity");

            var repo = MockRepository.GenerateMock<ILoungeRepository>();
            repo.Expect(x => x.RootFolderPath).Return(repoPath).Repeat.Any();
            repo.Expect(x => x.Load("0", "")).Return(null);
            repo.Expect(x => x.Load("1a", "part1")).Return(null);
            repo.Expect(x => x.Load("11a", "part1\\part11")).Return(null);

            repo.PrefetchAllEntities();

            Directory.Delete(repoPath, true);

            repo.VerifyAllExpectations();
        }
    }
}
